﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using sixgod.Enum.System;
using SqlSugar;

namespace sixgod.Model.System.Menu
{
    [SugarTable("SystemMenu","系统功能菜单")]
    public class SystemMenu:ModelBase
    {
        /// <summary>
        /// 功能名
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 菜单类型
        /// </summary>
        public MenuTypeEnum Type { get; set; }

        /// <summary>
        /// 排列顺序
        /// </summary>
        public int Order { get; set; }

        /// <summary>
        /// 路由地址
        /// </summary>
        [SugarColumn(IsNullable = true)]
        public string? Route { get; set; }

        /// <summary>
        /// 组件路径
        /// </summary>
        [SugarColumn(IsNullable = true)]
        public string? ComponentRoute { get; set; }

        /// <summary>
        /// 父级ID
        /// </summary>
        [SugarColumn(IsNullable = true)]
        public string? ParentCode { get; set; }

        /// <summary>
        /// 权限代码
        /// </summary>
        public string PermissionCode { get; set; }

        [SugarColumn(IsNullable = true)]
        public bool? Status {get;set;}

        /// <summary>
        /// 格式化 认证
        /// </summary>
        public void Format()
        {
            if (Type==MenuTypeEnum.Catalog)
            {
                ComponentRoute = null;
            }
            else if (Type==MenuTypeEnum.Operation)
            {
                Route = null;
                ComponentRoute = null;
            }
        }

        public override (bool, string) Verify()
        {
            return (false, null);
        }
    }
}
